package com.hdaccp.hadoop.mr2;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class Music implements Writable {
   private String songName ;
   private String singerName ;
   private String songType ;
   private String gender ;
   public Music(){
       super() ;
   }

   public Music(String songName,String singerName,String songType,String gender){
       this.songName = songName ;
       this.singerName = singerName ;
       this.songType = songType ;
       this.gender = gender ;
   }
   public void setMusic(String songName,String singerName){
       this.songName = songName ;
       this.singerName = singerName ;
   }
    public String getSongName() {
        return songName;
    }

    public void setSongName(String songName) {
        this.songName = songName;
    }

    public String getSingerName() {
        return singerName;
    }

    public void setSingerName(String singerName) {
        this.singerName = singerName;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(songName);
        dataOutput.writeUTF(singerName);
        dataOutput.writeUTF(songType);
        dataOutput.writeUTF(gender);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.singerName = dataInput.readUTF() ;
        this.songName = dataInput.readUTF() ;
        this.songType = dataInput.readUTF() ;
        this.gender = dataInput.readUTF() ;
    }


    @Override
    public String toString() {
        return songName + "\t" + singerName + "\t" + songType + "\t" + gender;
    }
}
